﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace PIM_ATE.Mods
{
    public partial class FrmCalConfig : Form
    {
        public FrmCalConfig()
        {
            InitializeComponent();
        }

        DataTable m_cal_dtShow;

        private void ctl_cal_btnModify_Click(object sender, EventArgs e)
        {
            if (MessageBox.Show("确认修改?", "警告", MessageBoxButtons.OKCancel) == DialogResult.OK)
            {
                int rowIndex = ctl_cal_dgvData.CurrentCell.RowIndex;
                int colIndex = ctl_cal_dgvData.CurrentCell.ColumnIndex;
                m_cal_dtShow.Rows[rowIndex][colIndex] = ctl_cal_tbSelected.Text;
            }
        }

        private void ctl_cal_btnNew_Click(object sender, EventArgs e)
        {
            if (MessageBox.Show("确认添加?", "警告", MessageBoxButtons.OKCancel) == DialogResult.OK)
            {

            }
        }

        private void ctl_cal_btnDelete_Click(object sender, EventArgs e)
        {
            if (MessageBox.Show("确认删除?", "警告", MessageBoxButtons.OKCancel) == DialogResult.OK)
            {
                int rowIndex = ctl_cal_dgvData.CurrentCell.RowIndex;
                m_cal_dtShow.Rows.RemoveAt(rowIndex);
            }
        }

        private void ctl_cal_dgvData_SelectionChanged(object sender, EventArgs e)
        {
            if (ctl_cal_dgvData.CurrentCell != null)
            {
                int colIndex = ctl_cal_dgvData.CurrentCell.ColumnIndex;
                ctl_cal_lblCellName.Text = ctl_cal_dgvData.Columns[colIndex].HeaderText;
                ctl_cal_tbSelected.Text = ctl_cal_dgvData.CurrentCell.Value.ToString();
                if (colIndex == 0)
                {
                    ctl_cal_tbSelected.Enabled = false;
                    ctl_cal_btnModify.Enabled = false;
                }
                else
                {
                    ctl_cal_tbSelected.Enabled = true;
                    ctl_cal_btnModify.Enabled = true;
                }
            }

        }
    }
}
